package com.trendplus.unitconverter;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.RadioGroup;
import android.widget.Toast;

public class UnitConverter extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unit_converter);
        findview();
        setlistener();
        
    }
    
    private RadioGroup myRadioGroup;
    private void findview() {
    	myRadioGroup=(RadioGroup)findViewById(R.id.radiogroup);
    }
    private void setlistener() {
    	myRadioGroup.setOnCheckedChangeListener(changeRadio);
    }
    
    
    private RadioGroup.OnCheckedChangeListener changeRadio=new RadioGroup.OnCheckedChangeListener() {
	    public void onCheckedChanged(RadioGroup group, int checkedId) {
			
			switch(checkedId) {
			    case R.id.lengthRadio:
			    	//Toast.makeText(UnitConverter.this,"lengthRadio",Toast.LENGTH_LONG).show();
			    	//Switch to report page
			    	Intent intent = new Intent();
			    	intent.setClass(UnitConverter.this, LengthCalculate.class);
			    	startActivity(intent);
			    	break;
			    case R.id.capacityRadio:
			    	//Toast.makeText(UnitConverter.this,"capacityRadio",Toast.LENGTH_LONG).show();
			    	Intent intentCapacity = new Intent();
			    	intentCapacity.setClass(UnitConverter.this, CapacityCalculate.class);
			    	startActivity(intentCapacity);
			    	break;
			    case R.id.weightRadio:
			    	//Toast.makeText(UnitConverter.this,"weightRadio",Toast.LENGTH_LONG).show();
			    	Intent intentWeight = new Intent();
			    	intentWeight.setClass(UnitConverter.this, WeightCalculate.class);
			    	startActivity(intentWeight);
			    	break;
			    case R.id.areaRadio:
			    	//Toast.makeText(UnitConverter.this,"areaRadio",Toast.LENGTH_LONG).show();
			    	Intent intentArea = new Intent();
			    	intentArea.setClass(UnitConverter.this, AreaCalculate.class);
			    	startActivity(intentArea);
			    	break;	
			    
			    default:
			    	Toast.makeText(UnitConverter.this,"Someting error",Toast.LENGTH_LONG).show();
			}
	    }

    };

}
